import React, {Component} from 'react';
import {
    View,
    Image,
    TouchableOpacity,
    StyleSheet,
    InteractionManager,
} from 'react-native';
import './utils/Global';

import HomeViewController from './modules/Home/home';
import TypeController from './modules/Type/type';
import MineController from './modules/Mine/mine';
import ClasslistViewController from './modules/Type/typeList';

class app extends Component {
    _NoFoundPages = () => {
        return (
            <View style={styles.container}>
                <Image style={styles.backgroundImage} source={Images.icon_404}/>
                <TouchableOpacity
                    style={styles.button}
                    onPress={() => {
                        console.log("点击跳转回首页");
                        InteractionManager.runAfterInteractions(() => {
                            // RNOpenOneVC这个也是写在原生里面的再PushNative中哦~
                            PushNative.RNPushVC({
                                viewController: 'HomeViewController',
                                moduleId: '10001'
                            });
                        });
                    }}/>
            </View>
        )
    };

    render() {
        const moduleId = this.props.moduleId;
        if (!moduleId) {
            return this._NoFoundPages();
        }
        const number = Number(moduleId);
        if (number < 20000) {
            if (moduleId === '10001') {
                return (<HomeViewController/>)
            }
            else if (moduleId === '10002') {
                return (<TypeController/>)
            }
            else if (moduleId === '10003') {
                return (<MineController/>)
            }
            else {
                return this._NoFoundPages();
            }
        }
        else {
            console.log("=============", moduleId, number);
            if (moduleId === '20001') {
                return (<ClasslistViewController/>)
            } else {
                return this._NoFoundPages();
            }
        }
    }
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        backgroundColor: '#fff',
    },
    backgroundImage: {
        position: 'absolute',
        top: 0,
        left: 0,
        bottom: 0,
        right: 0,

    },
    button: {
        opacity: 0,
        width: kScreenWidth,
        height: kScreenHeight,
    },
});

export default app;